import logging

def logger(name, level):
    logger = logging.getLogger(name)
    logger.setLevel(level)

    filename = '%s.log' % (name)
    fH = logging.FileHandler(filename)
    fH.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))

    cH = logging.StreamHandler()
    cH.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
    logger.addHandler(cH)
    logger.addHandler(fH)
    return logger
